import 'package:gluz/generated/json/base/json_convert_content.dart';
import 'package:gluz/app/data/shop/shop_cart_entity.dart';

ShopCartEntity $ShopCartEntityFromJson(Map<String, dynamic> json) {
  final ShopCartEntity shopCartEntity = ShopCartEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    shopCartEntity.id = id;
  }
  final String? userId = jsonConvert.convert<String>(json['userId']);
  if (userId != null) {
    shopCartEntity.userId = userId;
  }
  final String? productId = jsonConvert.convert<String>(json['productId']);
  if (productId != null) {
    shopCartEntity.productId = productId;
  }
  final String? productName = jsonConvert.convert<String>(json['productName']);
  if (productName != null) {
    shopCartEntity.productName = productName;
  }
  final String? productImage = jsonConvert.convert<String>(
      json['productImage']);
  if (productImage != null) {
    shopCartEntity.productImage = productImage;
  }
  final String? productImageUrl = jsonConvert.convert<String>(
      json['productImageUrl']);
  if (productImageUrl != null) {
    shopCartEntity.productImageUrl = productImageUrl;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    shopCartEntity.quantity = quantity;
  }
  final int? unitPrice = jsonConvert.convert<int>(json['unitPrice']);
  if (unitPrice != null) {
    shopCartEntity.unitPrice = unitPrice;
  }
  final int? totalPrice = jsonConvert.convert<int>(json['totalPrice']);
  if (totalPrice != null) {
    shopCartEntity.totalPrice = totalPrice;
  }
  final String? productSku = jsonConvert.convert<String>(json['productSku']);
  if (productSku != null) {
    shopCartEntity.productSku = productSku;
  }
  final String? productAttributes = jsonConvert.convert<String>(
      json['productAttributes']);
  if (productAttributes != null) {
    shopCartEntity.productAttributes = productAttributes;
  }
  final bool? isSelected = jsonConvert.convert<bool>(json['isSelected']);
  if (isSelected != null) {
    shopCartEntity.isSelected = isSelected;
  }
  final String? merchantId = jsonConvert.convert<String>(json['merchantId']);
  if (merchantId != null) {
    shopCartEntity.merchantId = merchantId;
  }
  final String? merchantName = jsonConvert.convert<String>(
      json['merchantName']);
  if (merchantName != null) {
    shopCartEntity.merchantName = merchantName;
  }
  final String? createdTime = jsonConvert.convert<String>(json['createdTime']);
  if (createdTime != null) {
    shopCartEntity.createdTime = createdTime;
  }
  final String? updatedTime = jsonConvert.convert<String>(json['updatedTime']);
  if (updatedTime != null) {
    shopCartEntity.updatedTime = updatedTime;
  }
  final int? deleted = jsonConvert.convert<int>(json['deleted']);
  if (deleted != null) {
    shopCartEntity.deleted = deleted;
  }
  return shopCartEntity;
}

Map<String, dynamic> $ShopCartEntityToJson(ShopCartEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['userId'] = entity.userId;
  data['productId'] = entity.productId;
  data['productName'] = entity.productName;
  data['productImage'] = entity.productImage;
  data['productImageUrl'] = entity.productImageUrl;
  data['quantity'] = entity.quantity;
  data['unitPrice'] = entity.unitPrice;
  data['totalPrice'] = entity.totalPrice;
  data['productSku'] = entity.productSku;
  data['productAttributes'] = entity.productAttributes;
  data['isSelected'] = entity.isSelected;
  data['merchantId'] = entity.merchantId;
  data['merchantName'] = entity.merchantName;
  data['createdTime'] = entity.createdTime;
  data['updatedTime'] = entity.updatedTime;
  data['deleted'] = entity.deleted;
  return data;
}

extension ShopCartEntityExtension on ShopCartEntity {
  ShopCartEntity copyWith({
    String? id,
    String? userId,
    String? productId,
    String? productName,
    String? productImage,
    String? productImageUrl,
    int? quantity,
    int? unitPrice,
    int? totalPrice,
    String? productSku,
    String? productAttributes,
    bool? isSelected,
    String? merchantId,
    String? merchantName,
    String? createdTime,
    String? updatedTime,
    int? deleted,
  }) {
    return ShopCartEntity()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..productId = productId ?? this.productId
      ..productName = productName ?? this.productName
      ..productImage = productImage ?? this.productImage
      ..productImageUrl = productImageUrl ?? this.productImageUrl
      ..quantity = quantity ?? this.quantity
      ..unitPrice = unitPrice ?? this.unitPrice
      ..totalPrice = totalPrice ?? this.totalPrice
      ..productSku = productSku ?? this.productSku
      ..productAttributes = productAttributes ?? this.productAttributes
      ..isSelected = isSelected ?? this.isSelected
      ..merchantId = merchantId ?? this.merchantId
      ..merchantName = merchantName ?? this.merchantName
      ..createdTime = createdTime ?? this.createdTime
      ..updatedTime = updatedTime ?? this.updatedTime
      ..deleted = deleted ?? this.deleted;
  }
}